<?php 
	namespace Index\Controller;
	use Think\Controller;
/**
 * 登录控制器
 */
	class LoginController extends Controller {

		public function index()
		{	
				//layout(false);
			if (isset($_SESSION['uid'])) {
				$this->success('你已登录', U('index/user/index'));
			}


			$question=D('vercode')->getOne();
	    	$this->assign('question',$question);

	       $this->display();
		}

		public function log()
		{
			D('vercode')->checkCode(I('post.vercode'));

			$email = I('post.email');

    	    $password = md5(I('post.pass'));

    		$res = M('user')->where("email='$email' and password='$password'")->find();

			// var_dump($res);
			if ($res) {

				$_SESSION['nickname']=$res['nickname'];
				$_SESSION['uid']=$res['id'];
				$_SESSION['face']=$res['face'];
				// $_SESSION['city']=$res['city'];
				// $_SESSION['sign']=$res['sign'];
				Reajax(0,登录成功);
			}else{
				Reajax(1,"登录密码或邮箱错误");
			}
			
					
		}

		public function out()
		{
			session_unset();
			session_destroy();
			$this->success("退出成功",U("index/index/index"));
		}







	};




?>